package com.health.service.impl;

import com.health.dao.SystemLogMapper;
import com.health.pojo.dto.SystemLogDTO;
import com.health.service.SystemLogService;
import java.lang.Boolean;
import java.lang.Override;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.health.exception.BusinessException;
import com.health.pojo.domain.SystemLogDO;
import java.util.Map;
import javax.validation.ValidationException;
import com.health.constant.ResultCodeConstant;
import java.util.Date;

/**
 * 系统日志管理的实现
 *
 * @author WUYU_MIN
 * @date 2025-04-29 23:51:18
 */
@Service
public class SystemLogServiceImpl implements SystemLogService {

    @Autowired
    private SystemLogMapper systemLogMapper;

    @Override
    public Boolean addSystemLog(SystemLogDTO systemLogDTO) {
        try {
            SystemLogDO systemLogDO = new SystemLogDO();
            systemLogDO.setUserId(systemLogDTO.getUserId());
            systemLogDO.setOperationType(systemLogDTO.getOperationType());
            systemLogDO.setOperationResult(systemLogDTO.getOperationResult());
            systemLogDO.setOperationTime(new java.util.Date());
            int result = systemLogMapper.insert(systemLogDO);
            return result > 0;
        } catch (ValidationException e) {
            throw new BusinessException(ResultCodeConstant.CODE_000001, ResultCodeConstant.CODE_000001_MSG);
        } catch (Exception e) {
            throw new BusinessException(ResultCodeConstant.CODE_999999, ResultCodeConstant.CODE_999999_MSG);
        }
    }
}
